﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using NetCoreCMS.Common;
using NetCoreCMS.IServices;

namespace NetCoreCMS.Web.Areas.Web.Controllers
{
    public class UserPointController : UserController
    {
        public string action = string.Empty;
        public int page=1;         //当前页码
        public int totalcount=0;   //OUT数据总数
        public IUser_point_logService _user_point_log { get; set; }
        public IActionResult Index()
        {
            action = Request.Query["act"];
            if (string.IsNullOrEmpty(action))
                action = "convert";
            int.TryParse(Request.Query["page"], out page);
            page = page > 0 ? page : 1;
            ViewBag.action = action;
            ViewBag.Page = page;
            string strwhere = "where user_id=" + GetUserInfo().id;
            var list = _user_point_log.GetList(page, 50, strwhere, "add_time desc,id desc");
            totalcount = _user_point_log.RecordCount(strwhere);
            string pageUrl = Utils.CombUrlTxt("/Web/Userpoint/Index", "page={0}&act={1}", "__id__",action);
            ViewBag.pagelist = Utils.OutPageList(50, page, totalcount, pageUrl, 8);
            return View(list);
        }
    }
}